import axios from '@/axios';
import store from '@/store';
import encript from '@script/encrypt'

export default {
    /**
     * 获取待传输的参数
     * @param {Number} sid 学号
     * @param {String} exp 日期表达式
     * @param {String} dept 部门
     * @param {String} group 小组
     */
    getParam(sid, exp, dept, group) {
        console.log()   
        let params = {
            exp: encript(exp)
        };
        if (sid != "") {
            let lock = encript(sid)
            if (isNaN(sid)) {
                params.name = lock
            } else {
                params.sid = lock
            }
        } else if (group == -1) {
            params.dept = dept == -1 ? '全部' : store.state.info.depts[dept].deptName
        } else if (group != -1) {
            params.dept = store.state.info.depts[dept].deptName
            params.group = store.state.info.depts[dept].groupList[group].groupName
        }
        return params
    },
    /**
     * 根据参数获取未签到列表
     * @param {Number} sid 学号
     * @param {String} exp 日期表达式
     * @param {String} dept 部门
     * @param {String} group 小组
     */
    async axiosGetRecord(sid, exp, dept, group) {
        const params = this.getParam(sid, exp, dept, group)
        let result = await axios({
            url: `/unsign/get/record`,
            params: params,
            method: "GET"
        })
        return result == null ? [] : result
    }
}